//#include <QtGui/QApplication>
#include <qtsingleapplication.h>
#include "maindialog.h"
#include <QProcess>

int main(int argc, char *argv[])
{
    QtSingleApplication instance("CubeControl", argc, argv);
    QString message;
    for (int a=1; a<argc; a++) {
        message += argv[a];
        if (a < argc-1) {
            message += " ";
        }
    }
    if (instance.sendMessage(message)) {
        return 0;
    }

    QProcess process;
    process.start("mkdir ini log");

    MainDialog mw;
    mw.argsMessage(message);
    mw.show();

    QObject::connect(&instance, SIGNAL(messageReceived(const QString&)), &mw, SLOT(argsMessage(const QString&)));
    instance.setActivationWindow(&mw, false);
    QObject::connect(&mw, SIGNAL(signalNeedToShow()), &instance, SLOT(activateWindow()));

    return instance.exec();
}
